package com.sky.aion;

import com.sky.aion.redis.Subscriber;
import com.sky.aion.utils.SpeakUtils;
import com.sky.aion.winio.WinIoUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class App {

    private static String logPath;

    /**
     * 读取配置文件
     * @return
     */
    public static void readConfigFile(String cfgFile) {
        try {
            InputStream in = App.class.getClassLoader().getResource(cfgFile).openStream();
            Properties prop = new Properties();
            prop.load(in);
            logPath = prop.getProperty("logPath");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



    public static void main(String[] args) {



        new Subscriber().synStart();
        System.out.println("redis监听线程启动成功！");

        SpeakUtils.exeSpeak();
        System.out.println("Speak线程启动成功！");

       /* if (WinIoUtils.WinIo.Instance.InitializeWinIo()){
            System.out.println("测试按键启动成功！！");
        }else {
            System.out.println("测试按键启动失败！！");
            return;
        }*/

        System.out.println("主程序启动成功！");
        //String logPath="D://Program Files (x86)//永恒之塔大师服//Chat.log";
        readConfigFile("aion.properties");
        System.out.println("日志文件路径："+logPath);
        LogView view = new LogView();
        final File tmpLogFile = new File(logPath);

        try {
            view.showLog(tmpLogFile);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
